#define _CRT_SECURE_NO_WARNINGS 1

#include <map>
#include <set>
#include <iostream>
#include <string>
using namespace std;
#include <vector>

class Solution1
{
public:
    bool uniqueOccurrences(vector<int>& arr)
    {
        map<int, int> countMap;
        for (auto& e : arr)
            ++countMap[e];

        set<int> s;
        for (auto& kv : countMap)
        {
            s.insert(kv.second);
        }
        return s.size() == countMap.size();
    }
};

class Solution2
{
public:
    bool uniqueOccurrences(vector<int>& arr)
    {
        int count[2021] = { 0 };
        for (int i = 0; i < arr.size(); ++i)
            ++count[arr[i] + 1000];

        bool fre[1001] = { false };
        for (int i = 0; i <= 2000; ++i)
        {
            if (count[i])
            {
                if (!fre[count[i]])
                    fre[count[i]] = true;
                else
                    return false;
            }
        }
        return true;
    }
};
